#!/bin/bash

ROOT_PATH=$(cd $(dirname $0) && pwd);

apt purge -y softether-vpnclient
apt autoremove -y

apt -y install softether-vpnclient

HOST=$(hostname)
PASS=$(cat $ROOT_PATH/softether-client/user.secret)

sh -c "echo '
NicCreate se0
AccountCreate prx /SERVER:prx.geocat.space:443 /HUB:DEFAULT /USERNAME:$HOST /NICNAME:se0
AccountPasswordSet prx /PASSWORD:$PASS /TYPE:standard
' > /tmp/softether.config"

sudo vpncmd localhost /CLIENT /in:/tmp/softether.config

rm /tmp/softether.config
